define(function(require, exports, module) {
	var $=require("jq.js");
	//控制焦点图上下切换
	var controlsMain  = $(".slide-control"),
		controls      = $(".slide-control").find("li"),
		firstControl  = controls.first(),
		lastControl   = controls.last(),
		focusLeftBtn  = $(".slide-control-left"),
		focusRightBtn = $(".slide-control-right");
		
	focusLeftBtn.click(function(){
		var prev = controlsMain.find(".selected").prev();
		prev = prev.get(0)?prev:lastControl;
		prev.mouseover();
	});
	focusRightBtn.click(function(){
		var next = controlsMain.find(".selected").next();
		next = next.get(0)?next:firstControl;
		next.mouseover();
	});
	
	//最新热点滚动
	var scrollMain = $(".J_SlideScroll"),
		items      = scrollMain.find("li"),
		itemsSize  = items.size(),
		itemBox    = scrollMain.find("ul"),
		leftBtn    = scrollMain.find(".leftBtn"),
		rightBtn   = scrollMain.find(".rightBtn");
	
	rightBtn.hover(function(){
		$(this).addClass("no");
	},function(){
		$(this).removeClass("no");
	}).click(function(){
		
		if(!itemBox.is(":animated")){
			itemBox.animate({marginLeft:-180},function(){
				$(this).children().first().appendTo(this);
				$(this).css("marginLeft",0);
			});
		};
	});
	leftBtn.hover(function(){
		$(this).addClass("no");
	},function(){
		$(this).removeClass("no");
	}).click(function(){
		if(!itemBox.is(":animated")){
			itemBox.css("marginLeft",-180);
			itemBox.children().last().prependTo(itemBox);
			itemBox.animate({marginLeft:0});
		};
	});
	//设置宽度
	itemBox.width(181*itemsSize);
	var timer = null;
	var autoPlay = function(){
		 timer = window.setInterval(function(){
				rightBtn.click();
		},5000);
	};
	autoPlay();
	var clearTimer = null;
	scrollMain.hover(function(){
		window.clearInterval(timer);
	},function(){
		autoPlay();
	});
	
	//楼层定位
	$(".category").hover(function(){
		var poplist = $(this).find(".poplist");
		poplist.show();	
		$(this).find("a").css({"color":"black"})
		
	},function(){
		var poplist = $(this).find(".poplist");
		poplist.hide();		
		$(this).find("a").css({"color":"white"});
	});

	//点击选中
	var allPa = $(".category-plugin .side a").click(function(){
		$(".category-plugin .side a").removeClass("selected");
		$(this).addClass("selected");
	});
	
	var pTops = [];
	$(".floor-mod").each(function(){
		pTops.push($(this).offset().top);
	});
	
	//浮动效果and自动选中
	$(window).scroll(function(){
	  var top = (document.documentElement.scrollTop||document.body.scrollTop||window.pageYOffset||0)-20;
	  if(top>600){
		  $(".sidebar").css({
			  top:0,
			  marginTop:0
		  });
		   $.each(pTops,function(index,pTop){
			  if(pTop>top) {
				  allPa.removeClass("selected");
				  allPa.eq(index).addClass("selected");
			  	  return false;
			  };
		   });
	  }else{
		  $(".sidebar").css({
			  top:"50%",
			  marginTop:150
		  });
	  };
	 });
	
	//分类插件文字折行
	$(".update-plugin-html").each(function(){
		var $this=$(this);
		var html =$this.html();
		if(html.length>2){
			html=html.substring(0,2)+"<br>"+html.substring(2);
		}
		$this.html(html);
	});
	
	//分类栏目效果
	$(".category a").hover(function(){
		$(this).css({
			"color":"red",
			"text-decoration": "underline"
		});
	},function(){
		$(this).css({
			"color":"black",
			"text-decoration": "none"
		});
	});
});